Skip to content

Conversation

@chaance
Copy link
Contributor

@chaance chaance commented Dec 12, 2025

This is the RR equivalent of the same function exposed in the Next SDK. The main difference is that this version only accepts a request rather than an arbitrary URL to keep things a little simpler. We can expand this functionality in the future if it seems important enough.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 12, 2025

Greptile Overview

Greptile Summary

This PR adds a new saveSession function for manual authentication flows (email verification, custom auth, etc.) and refactors refreshSession to use it internally.

  • Added saveSession() function that encrypts and commits session data to cookies
  • Refactored refreshSession() to delegate session persistence to saveSession()
  • Added RefreshedSession interface and explicit return type for refreshSession()
  • Updated encryptSession() to accept AuthenticationResponse in addition to Session
  • Added comprehensive test coverage for the new function

Issue found: saveSession is not exported from src/index.ts, making it inaccessible to library consumers.

Confidence Score: 3/5

  • Safe to merge after addressing the missing export in index.ts
  • The implementation is clean and well-tested, but the new function isn't exported from the package's public API, which defeats the purpose of the PR
  • src/index.ts needs to export saveSession for the feature to be usable

Important Files Changed

File Analysis

Filename Score Overview
src/session.ts 4/5 Adds new saveSession function for manual auth flows and refactors refreshSession to use it internally. Well-structured implementation with proper types.
src/session.spec.ts 5/5 Adds comprehensive test coverage for the new saveSession function, verifying session storage, cookie commitment, and JWT encryption.

Sequence Diagram

sequenceDiagram
    participant User as User Code
    participant saveSession as saveSession()
    participant storage as SessionStorage
    participant iron as iron-session

    User->>saveSession: saveSession(authResponse, request)
    saveSession->>storage: getSessionStorage()
    storage-->>saveSession: {getSession, commitSession}
    saveSession->>storage: getSession(cookie)
    storage-->>saveSession: cookieSession
    saveSession->>iron: encryptSession(newSession)
    iron-->>saveSession: encrypted JWT
    saveSession->>storage: cookieSession.set('jwt', encryptedJWT)
    saveSession->>storage: commitSession(cookieSession)
    storage-->>saveSession: Set-Cookie header value
    saveSession-->>User: Session with headers
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Member

@nicknisi nicknisi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@chaance chaance merged commit bd07e65 into main Dec 12, 2025
9 checks passed
@chaance chaance deleted the chance/save-session branch December 12, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants